# Go to http://wiki.merbivore.com/pages/init-rb
 
require 'config/dependencies.rb'
 
use_orm :activerecord
use_test :rspec
use_template_engine :erb

#____________________DON'T CHANGE THESE SETTINGS____________________
#_____OVERWRITE CONFIGURATION IN OWN CONFIG/ENGINE_CONFIG.RB________
Merb::Config.use do |c|
  c[:environment] = 'development' #development, production, testing
  c[:port] = 3000
  c[:host_name] = "localhost"
  c[:use_mutex] = false #use of ActiveRecord in multithreaded environment can be dangerous!
  c[:cluster] = 1 #use in production mode for starting a mongrel cluster with X instances
  
  c[:render_form_only] = false # renders only the xform or the whole page for a transition
  c[:gui_debug] = true #more detailed web interface
  c[:locator_caching] = true
  c[:data_path] = 'data'
  c[:enable_auth] = false #if false, a random username + password is set
  c[:redirect_after_fire] = :current_case #specify, where to redirect after firing a transition: :current_case, :current_petri_net or any URL as String
  
  c[:session_id_key] = 'session_id'
  c[:session_secret_key] = '4c4936389dc96a7704153d05928a10302d742d78'
  c[:session_store] = 'cookie'
  
  c[:use_reevaluation] = false
end
require 'config/engine_config' if File.exist?("config/engine_config.rb")
Merb::Config.use do |c|
  c[:root] = "http://#{c[:host_name]}:#{c[:port]}"
end
 
Merb::BootLoader.before_app_loads do
  # This will get executed after dependencies have been loaded but before your app's classes have loaded.
end
 
Merb::BootLoader.after_app_loads do
  ### Add dependencies here that must load after the application loads:
  require 'pnml_parser'
  # dependency "magic_admin" # this gem uses the app's model classes
  
  PetrinetObserver.instance
  TransitionObserver.instance
  ArcObserver.instance
  TokenObserver.instance

  $EXECLOG = {}
  
  #overwrites Merbs default-contenttype for html, because engine should always deliver xhtml
  Merb.add_mime_type(:html, :to_html, %w[application/xhtml+xml text/html application/html])
  Merb.add_mime_type(:atom, :to_atom, %w[application/atom+xml]) 
  Merb.add_mime_type(:pnml, :to_pnml, %w[application/pnml+xml])
end
